package com.txsj.scan.activity;


import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.txsj.scan.R;
import com.txsj.scan.adapter.AllocationDetailsRcAdapeter;
import com.txsj.scan.base.BaseActivity;
import com.txsj.scan.base.BasePresenter;
import com.txsj.scan.bean.AllocationDetailsBean;
import com.txsj.scan.utils.glide.GlideImgManager;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by wwb on 2019/5/26.
 * 调拨历史  调拨详情 不可以编辑的
 */
public class AllocationDetailsActivity extends BaseActivity {


    ImageView ivGoods;
    TextView tvGoods;
    TextView tvGoodsNum;
    TextView tvAllCount;
    RecyclerView recyclerView;
    TextView tvCommit;

    //    activity_allocation_details
    private List<String> ss = new ArrayList<>();
    private AllocationDetailsRcAdapeter adapter;
    private AllocationDetailsBean data;
    private List<AllocationDetailsBean.DetailsBean> list = new ArrayList<>();
    private int total;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_allocation_details);
        findId();
    }

    private void findId() {
        ivGoods = (ImageView) findViewById(R.id.iv_goods);
        tvGoods = (TextView) findViewById(R.id.tv_goods);
        tvGoodsNum = (TextView) findViewById(R.id.tv_goods_num);
        tvAllCount = (TextView) findViewById(R.id.tv_all_count);
        tvCommit = (TextView) findViewById(R.id.tv_commit);
        recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        initData();
    }


    protected void initData() {
        data = (AllocationDetailsBean) getIntent().getSerializableExtra("data");
        long gs1_num = getIntent().getLongExtra("gs1_num", 0);
        if (null == data || gs1_num == 0) return;
        for (int i = 0; i < data.getDetails().size(); i++) {
            if (data.getDetails().get(i).getGs1_num() == gs1_num) {
                list.add(data.getDetails().get(i));
                total += data.getDetails().get(i).getGoods_count();
            }
        }
        GlideImgManager.getLoadImg(this, list.get(0).getGoods_img(), ivGoods);
        tvGoods.setText(list.get(0).getGoods_name());
        tvGoodsNum.setText(list.get(0).getGoods_num());
        tvAllCount.setText(total + "");
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        adapter = new AllocationDetailsRcAdapeter(this);
        recyclerView.setAdapter(adapter);

        adapter.setList(list);
    }


    @Override
    protected BasePresenter providePresenter() {
        return null;
    }
}
